package cn.powerone.scm.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmSequenceParm;
import cn.powerone.scm.service.IScmSequenceParmService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 序号参数Controller
 * 
 * @author PowerOne
 * @date 2025-08-05
 */
@RestController
@RequestMapping("/scm/scmSequenceParm")
public class ScmSequenceParmController extends BaseController
{
    @Autowired
    private IScmSequenceParmService scmSequenceParmService;

    /**
     * 查询序号参数列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmSequenceParm:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmSequenceParm scmSequenceParm)
    {
        startPage();
        List<ScmSequenceParm> list = scmSequenceParmService.selectScmSequenceParmList(scmSequenceParm);
        return getDataTable(list);
    }

    /**
     * 导出序号参数列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmSequenceParm:export')")
    @Log(title = "序号参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmSequenceParm scmSequenceParm)
    {
        List<ScmSequenceParm> list = scmSequenceParmService.selectScmSequenceParmList(scmSequenceParm);
        ExcelUtil<ScmSequenceParm> util = new ExcelUtil<ScmSequenceParm>(ScmSequenceParm.class);
        util.exportExcel(response, list, "序号参数数据");
    }

    /**
     * 获取序号参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmSequenceParm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmSequenceParmService.selectScmSequenceParmById(id));
    }

    /**
     * 新增序号参数
     */
    @PreAuthorize("@ss.hasPermi('scm:scmSequenceParm:add')")
    @Log(title = "序号参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmSequenceParm scmSequenceParm)
    {
        return toAjax(scmSequenceParmService.insertScmSequenceParm(scmSequenceParm));
    }

    /**
     * 修改序号参数
     */
    @PreAuthorize("@ss.hasPermi('scm:scmSequenceParm:edit')")
    @Log(title = "序号参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmSequenceParm scmSequenceParm)
    {
        return toAjax(scmSequenceParmService.updateScmSequenceParm(scmSequenceParm));
    }

    /**
     * 删除序号参数
     */
    @PreAuthorize("@ss.hasPermi('scm:scmSequenceParm:remove')")
    @Log(title = "序号参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmSequenceParmService.deleteScmSequenceParmByIds(ids));
    }
}
